#pragma once

#include <MeshVS_DataSource.hxx>
#include <Poly_Triangulation.hxx>
#include <Precision.hxx>
#include <TColStd_HArray2OfInteger.hxx>
#include <TColStd_HArray2OfReal.hxx>

class OCCMesh_Data : public MeshVS_DataSource
{
    DEFINE_STANDARD_RTTIEXT(OCCMesh_Data, MeshVS_DataSource)

  public:
    OCCMesh_Data(Handle(Poly_Triangulation) plyTri);

    // 重载几何函数
    Standard_Boolean GetGeom(const Standard_Integer ID, const Standard_Boolean IsElement, TColStd_Array1OfReal &Coords,
                             Standard_Integer &NbNodes, MeshVS_EntityType &Type) const Standard_OVERRIDE;

    // 重载几何类型函数
    Standard_Boolean GetGeomType(const Standard_Integer ID, const Standard_Boolean IsElement,
                                 MeshVS_EntityType &Type) const Standard_OVERRIDE;

    // 重载
    Standard_Address GetAddr(const Standard_Integer ID, const Standard_Boolean IsElement) const Standard_OVERRIDE;

    // 重载节点函数
    Standard_Boolean GetNodesByElement(const Standard_Integer ID, TColStd_Array1OfInteger &NodeIDs,
                                       Standard_Integer &NbNodes) const Standard_OVERRIDE;

    // 重载法向函数
    Standard_Boolean GetNormal(const Standard_Integer Id, const Standard_Integer Max, Standard_Real &nx,
                               Standard_Real &ny, Standard_Real &nz) const Standard_OVERRIDE;

    const TColStd_PackedMapOfInteger &GetAllNodes() const Standard_OVERRIDE;
    const TColStd_PackedMapOfInteger &GetAllElements() const Standard_OVERRIDE;
    Handle(Poly_Triangulation) GetTriangulation() const;

  private:
    Handle(Poly_Triangulation) m_plyTri;
    TColStd_PackedMapOfInteger m_nodes;
    TColStd_PackedMapOfInteger m_elements;
    Handle(TColStd_HArray2OfInteger) m_elemNodes;
    Handle(TColStd_HArray2OfReal) m_nodeCoords;
    Handle(TColStd_HArray2OfReal) m_elemNormals;
};
